const mongoose = require('mongoose');
// const db = require("../common/config/db");
const Schema = mongoose.Schema

//创建schema用户实体
const userSchema = new Schema({
    user_id: {type: Number, unique: true},
    openid: {type: String},
    nickname: {type: String},
    username: {type: String},
    password: {type: String},
    avatar: {type: String},
    phone: {type: String},
    create_time: {type: Date, default: Date.now},
    level: {type: Number, default: 0},
});

//创建模型
// const User = db.createModel(userSchema, 'users');
const User = mongoose.model('users', userSchema);

//创建model
// module.exports = mongoose.model('User', userSchema, 'users');
module.exports = User;

